<?php

namespace Platform\Models\Pay;

use Platform\Models\BaseModel;

class RewardPayOrder extends BaseModel {

    const TABLE_NAME = 'reward_pay_order';

    public function initialize() {
        parent::initialize();
        $this->setSource(self::TABLE_NAME);
    }

    private $id;
    private $orderNo;
    private $cash;
    private $createTime;
    private $status;
    private $updateTime;
    private $openId;
    private $type;
    
    public function getType() {
        return $this->type;
    }

    public function setType($type) {
        $this->type = $type;
    }

    
    public function getId() {
        return $this->id;
    }

    public function getOrderNo() {
        return $this->orderNo;
    }

    public function getCash() {
        return $this->cash;
    }

    public function getCreateTime() {
        return $this->createTime;
    }

    public function getStatus() {
        return $this->status;
    }

    public function getUpdateTime() {
        return $this->updateTime;
    }

    public function getOpenId() {
        return $this->openId;
    }

    public function setId($id) {
        $this->id = $id;
    }

    public function setOrderNo($orderNo) {
        $this->orderNo = $orderNo;
    }

    public function setCash($cash) {
        $this->cash = $cash;
    }

    public function setCreateTime($createTime) {
        $this->createTime = $createTime;
    }

    public function setStatus($status) {
        $this->status = $status;
    }

    public function setUpdateTime($updateTime) {
        $this->updateTime = $updateTime;
    }

    public function setOpenId($openId) {
        $this->openId = $openId;
    }

    public function columnMap() {
        //列名 =》 属性名
        return [
            'id' => 'id',
            'order_no' => 'orderNo',
            'cash' => 'cash',
            'create_time' => 'createTime',
            'status' => 'status',
            'update_time' => 'updateTime',
            "open_id" => "openId",
            "type"=>"type",
        ];
    }

    /**
     * 获取一条加锁的数据
     * @param $id
     * @param $columns
     */
    public function getForUpdateDataById($id, $columns = '') {
        $query = [
            "conditions" => "$this->pk = :id:",
            "bind" => [
                "id" => $id
            ],
            "for_update" => true
        ];
        if ($columns) {
            $query['columns'] = $columns;
        }
        $data = self::findFirst($query);
        return $data;
    }

}
